#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=600;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  /*
  for(LL i=1;i<=16;i++){
    cin>>a[i];
  }
  LL gcd=a[1];LL lcm=0;
  for(LL i=1;i<=16;i++){
     lcm=gcd/__gcd(gcd,a[i])*a[i];
     gcd=lcm;
  }
  cout<<lcm<<"\n";*/
  LL n,m;cin>>n>>m;
  for(LL i=1;i<=n;i++){
    for(LL j=1;j<=m;j++){
        cin>>a[i][j];
        if((i+j)&1){
            cout<<720720<<" ";
        }
        else{
            cout<<720720+a[i][j]*a[i][j]*a[i][j]*a[i][j]<<" ";
        }
    }
    cout<<"\n";
  }
return 0;
}
